import * as actions from '../actions/index';

// 页面初始化数据
export const initialState = {
  GC: {},
  isPostingGC: false,
  repo_size: 0,
  projectInfo: null,
  repoAdminOperation: null,
};
const defaultAction = {
  type: 'doNothing',
};

export default function index(state = initialState, action = defaultAction) {
  switch (action.type) {
    case actions.UPDATE_DATA:
      return { ...state, ...action.data };
    case actions.RECEIVE_REPO_SETTING:
      return {
        ...state,
        repoAdminOperation: action.data.repo_admin_operation,
      };
    case actions.RESET_DATA:
      return initialState;
    default:
      return state;
  }
}
